package com.mxf.code.service.impl;

import com.mxf.code.repository.EntityManagerRepository;
import com.mxf.code.request.EntityDataAddRequest;
import com.mxf.code.request.EntityDataDetailRequest;
import com.mxf.code.request.EntityDataEditRequest;
import com.mxf.code.request.EntityDataPageRequest;
import com.mxf.code.response.EntityDataDetailResponse;
import com.mxf.code.response.EntityDataPageResponse;
import com.mxf.code.service.EntityManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author mxf
 * @version 1.0
 * @description: 实体管理
 * @date 2023/5/10
 */
@Service
public class EntityManagerServiceImpl implements EntityManagerService {

    @Autowired
    private EntityManagerRepository entityManagerRepository;

    @Override
    public List<EntityDataPageResponse> pageData(EntityDataPageRequest request) {
        //return entityManagerRepository.pageData(request, 0, 10);
        return null;
    }

    @Override
    public void saveEntryData(EntityDataAddRequest request) {
        entityManagerRepository.saveEntryData(request.getOntologyId(), request.getEntityProperties());
    }

    @Override
    public void modifyEntryData(EntityDataEditRequest request) {
        entityManagerRepository.modifyEntryData(request.getId(), request.getEntityProperties());
    }

    @Override
    public EntityDataDetailResponse getDetail(EntityDataDetailRequest request) {
        return entityManagerRepository.getEntityById(request.getOntologyId(), request.getEntityId());
    }

    @Override
    public void delete(Long[] ids) {
        for (Long id : ids) {
            entityManagerRepository.delete(id);
        }
    }
}
